<template>
    <div id="app" class="search">
        <div class="nav">
            <div>
                <input type="text" v-model="searchVal" placeholder="少年你想要查找什么...">
            </div>
            <div>
                <span @click="closeClick" class="glyphicon glyphicon-remove-circle"></span>
            </div>
        </div>
        <div class="title">
            文章
        </div>
        <div class="column">
            <ul>
                <li v-for="(item,index) in lists" @click="detailsClick(index)">
                    <div>
                        <span class="glyphicon glyphicon-file" id="colco"></span>
                    </div>
                    <div>
                        <div id="colco">
                            {{item.title}}
                        </div>
                        <div id="colco">
                            {{item.preface}}
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</template>
<script>
    import { mapActions } from 'vuex'
    export default {
        name: 'search',
        props: ['lists'],
        data() {
            return {
                searchVal: ''
            }
        },
        created: function () {
            var self = this

        },
        mounted: function () {
        },
        watch: {
            searchVal: function (val, oldVal) {
                this.$emit('search', val)
            }
        },
        methods: {
            closeClick() {
                this.$emit('close', 'clo')
            },
            detailsClick(index) {
                this.$emit('details', index)
            },
             ...mapActions(['getHotSearchLists'])
        },

    }

</script>
<style scoped>
    .search {
        width: 100%;
        height: 100%;
    }
    
    .search>div {
        width: 100%;
        overflow: hidden;
    }
    
    .nav {
        display: flex;
    }
    
    .nav>div:nth-child(2) {
        width: 40px;
        height: 44px;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .nav>div:nth-child(2) span {
        font-size: 19px;
        cursor: pointer;
    }
    
    .nav input {
        width: 100%;
        height: 44px;
        padding-left: 15px;
        font-size: 18px;
        line-height: 44px;
        border: 0;
    }
    
    .nav>div:nth-child(1) {
        width: 500px;
    }
    
    .title {
        height: 35px;
        border-top: 1px solid #e2e2e2;
        border-bottom: 1px solid #e2e2e2;
        background-color: #f7f7f7;
        color: #9a9a9a;
        font-size: 15px;
        padding-left: 12px;
        line-height: 35px;
    }
    
    .column {}
    
    .column>ul {
        width: 100%;
        height: 530px;
        overflow-y: scroll;
    }
    
    .column>ul>li {
        height: 55px;
        margin-top: 10px;
        display: flex;
        cursor: pointer;
    }
    
    .column>ul>li:hover {
        background-color: #58b7ff;
    }
    
    .column>ul>li:hover #colco {
        color: #fff;
    }
    
    .column li>div:nth-child(1) {
        margin-left: 20px;
        width: 35px;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .column li>div:nth-child(1) span {
        font-size: 17px;
    }
    
    .column li>div:nth-child(2) {
        width: 475px;
        height: 100%;
    }
    
    .column li>div:nth-child(2)>div:nth-child(1) {
        width: 100%;
        line-height: 30px;
        height: 30px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
    
    .column li>div:nth-child(2)>div:nth-child(2) {
        width: 100%;
        height: 25px;
        line-height: 19px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        color: #9a9a9a;
    }
</style>